package com.sloera.spring.aop.impl;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author sloera
 * @create 2020/4/8
 */
public class Main {
    public static void main(String[] args) {
        //创建 Spring 的 IOC 容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("aop-context-application.xml");

        //从 IOC 容器中获取 bean 的实例
        ArithmeticCaculator arithmeticCaculator = ctx.getBean(ArithmeticCaculator.class);
        //配置文件加注解后生成的是代理对象
        System.out.println(arithmeticCaculator.getClass().getName());

        //使用bean
        int result = arithmeticCaculator.add(1, 2);
        System.out.println(result);
        result = arithmeticCaculator.div(10, 2);
        System.out.println(result);
        //result = arithmeticCaculator.div(10, 0);
        //System.out.println(result);
    }
}